from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import time

driver=webdriver.Firefox()
day4=driver.window_handles
print(day4)
driver.get('http://10.59.9.14:7003/')
time.sleep(2)
driver.find_element(By.XPATH,'/html/body/div[1]/div/div[2]/ul/li[1]/a').click()
time.sleep(2)
dl=driver.find_element(By.TAG_NAME,'span').text
print(dl)
# ①　登录成功
driver.find_element(By.CLASS_NAME,'regi-input').send_keys('13811033962')
driver.find_element(By.NAME,'password').send_keys('123456')
time.sleep(5)
driver.find_element(By.CSS_SELECTOR,'.finish-btn').click()
time.sleep(2)

# ③　首页商品列表
driver.find_element(By.XPATH,'/html/body/div[3]/div[2]/ul/li[1]/a').click()
driver.switch_to.window(driver.window_handles[-1])
time.sleep(5)
# ②　商品搜索
ss=driver.find_element(By.XPATH,'//input[@class="search-input"]')
ss.send_keys('手机')
ss.send_keys(Keys.ENTER)
time.sleep(5)
# ④　商品详情
driver.find_element(By.XPATH,'/html/body/div[5]/div[2]/'
                             'div[2]/div[1]/ul/li/div[1]/span'
                             '/a/img').click()
time.sleep(5)
# ⑤　加入购物车
driver.find_element(By.LINK_TEXT,'加入购物车').click()
time.sleep(5)
driver.find_element(By.CLASS_NAME,'nav-settcart').click()
time.sleep(5)
# ⑥　确认订单
driver.find_element(By.XPATH,'/html/body/div[4]/form/div[1]/div[1]/table/tbody/tr[2]/td[1]/input').click()
time.sleep(5)
# ⑦　创建订单并支付
driver.find_element(By.CLASS_NAME,'ask-btn').click()
time.sleep(5)
driver.find_element(By.ID,'order-button').click()
time.sleep(5)
# 退出浏览器技术
driver.quit()





















